﻿using System;

namespace DebIt.Common.Model
{
    public class ClientLoanState : DbStoredItem
    {
        #region variables

        private DateTime? _timestamp;
        private bool _isPaid;
        private Client _client ;
        private Loan _loan;

        #endregion


        #region properties

        public int ClientLoanStateId { get; set; }

        public DateTime? Timestamp
        {
            get { return _timestamp; }
            set
            {
                if (_timestamp == value) return;
                SendPropertyChanging(() => ClientLoanStateId);
                _timestamp = value;
                SendPropertyChanged(() => ClientLoanStateId);
            }
        }

        public bool IsPaid
        {
            get { return _isPaid; }
            set
            {
                if (_isPaid == value) return;
                SendPropertyChanging(() => IsPaid);
                _isPaid = value;
                if (_isPaid)
                    Timestamp = DateTime.Now;
                SendPropertyChanged(() => IsPaid);
            }
        }

        public Client Client
        {
            get { return _client; }
            set
            {
                if (_client == value) return;
                SendPropertyChanging(() => Client);
                _client = value;
                SendPropertyChanged(() => Client);
            }
        }

        public Loan Loan
        {
            get { return _loan; }
            set
            {
                if (_loan == value) return;
                SendPropertyChanging(() => Loan);
                _loan = value;
                SendPropertyChanged(() => Loan);
            }
        }

        #endregion
    }
}
